import React, { Component } from 'react';
import {
    Form, Icon, Input, Button, Checkbox,
  } from 'antd';

import { BrowserRouter as Router, Route ,Switch} from "react-router-dom";
import myIndex from './Index'

class LoginForm extends Component {
    constructor(props) {
        super(props);
        this.state = {  };
    }


    handleSubmit = (e) => {
        e.preventDefault();
        this.props.form.validateFields((err, values) => {
          if (!err) {
            console.log('Received values of form: ', values);

            console.log(123)
            window.location.href='/index'
          }else{
            console.log("exist  erorrs")
          }
        });
      }
    
      render() {

        const { getFieldDecorator } = this.props.form;
        return (
      
          <div style={{paddingTop:'240px',backgroundColor:'yield'}}>


          <Form onSubmit={this.handleSubmit} className="login-form">
            <Form.Item>
              {getFieldDecorator('userName', {
                rules: [{ required: true, message: 'Please input your username!' }],
              })(
                <Input prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />} placeholder="Username" />
              )}
            </Form.Item>
            <Form.Item>
              {getFieldDecorator('password', {
                rules: [{ required: true, message: 'Please input your Password!' }],
              })(
                <Input prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} type="password" placeholder="Password" />
              )}
            </Form.Item>
            <Form.Item style={{textAlign:"left"}}>
              {getFieldDecorator('remember', {
                valuePropName: 'checked',
                initialValue: true,
              })(
                <Checkbox >Remember me</Checkbox>
              )}
              <a  href="#" style={{marginLeft:"68px"}}>Forgot password</a>
              <Button type="primary" htmlType="submit" style={{width:300}}>
                Log in
              </Button>
              Or <a href="#">register now!</a>
            </Form.Item>
          </Form>

            
          </div>
         
           
        );
      
      }
}

export default Form.create()(LoginForm);